<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script src="./lib/vue.js"></script>
</body>

</html>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./lib/vue.js"></script>
</head>

<body>
  <div id="app">
    <h3 v-auth>只有张三才能看到的信息</h3>
    <hr>
    <button @click="setToken(1)">张三</button>
    <button @click="setToken(2)">李四</button>
  </div>

  <script type="module">
    import store from './lib/Store.js'

    Vue.directive('auth', {
      inserted(el) {
        if (!['1'].includes(store.get('token'))) {
          el.parentNode.removeChild(el)
        }
      }
    })


    let vm = new Vue({
      el: '#app',
      data: {
      },
      methods: {
        setToken(value) {
          store.set('token', value)
        }
      }
    })
  </script>
</body>

</html>